{	Problem: http://codeforces.ru/problemset/problem/83/A
	Verdict: Accepted
}
var
    a:array[0..100010] of int64;
    i,j,n:longint;
    r,c:int64;
begin
read(n);
for i:=1 to n do read(a[i]);
r:=0;
i:=1;
while i<=n do begin
    j:=i;
    while (j<=n) and (a[i]=a[j]) do inc(j);
    c:=j-i;
    inc(r,c*(c+1) div 2);
    i:=j;
end;
write(r);
end.